﻿using Direct.IDAL.User.Jurisdiction;
using DirectSell.Common.Filter;
using DirectSell.Common.Session;
using DirectSell.IBLL;
using DirectSell.Model.ServiceCenter;
using DirectSell.Model.User;
using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace DirectSell.WebLayer.Areas.User.Controllers
{
    /// <summary>
    /// 服务中心申请
    /// </summary>
    public class ServiceCenterController : Controller
    {
        #region 依赖注入--郭文昊--2018年8月19日03:46:57
        /// <summary>
        /// 用户注册
        /// </summary>
        [Dependency("ServiceCenter")]
        public IOperation register { get; set; }

        [Dependency]
        protected IModifyInfoRespository modifydal { get; set; }

        #endregion

        #region 主页
        /// <summary>
        /// 服务中心申请主页
        /// </summary>
        /// <returns></returns>
        [LoginFilter(IsCheck =true)]
        public ActionResult Index()
        {
            return View();
        }
        #endregion

        #region 申请操作
        /// <summary>
        /// 服务中心申请操作
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<UserRespCode> CenterApply(ServiceCenter model)
        {
            model.ServiceCenterCode = SessionInfo.GetSession().UserCode;
            if(!await modifydal.CheckSecondPassword(model.ServiceCenterCode, model.SecondPassWord))
            {
                return UserRespCode.二级密码输入错误;
            }

            return register.DoOperation(model);
        }
        #endregion
    }
}